package com.extension.company.common.widget;

import android.graphics.Rect;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
 * 作者:zwk
 * 联系方式：497981239@qq.com
 * 时间：on 2019/7/15 21:47
 * 功能：单recycleView 水平的分割线
 */
public class LinearSpaceItemDecoration extends RecyclerView.ItemDecoration {
	private boolean include;
	private int space;

	public LinearSpaceItemDecoration(boolean include, int space) {
		this.include = include;
		this.space = space;
	}

	@Override
	public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
		super.getItemOffsets(outRect, view, parent, state);
		if (include) {
			outRect.top = space;
			outRect.left = space;
			outRect.right = space;
		} else {
			outRect.bottom = space;
			outRect.left = space;
			outRect.right = space;
		}
	}
}
